package com.tm.service.impl;

import com.tm.mapper.SysuserMapper;
import com.tm.pojo.SysuserPojo;
import com.tm.pojo.vo.SysuserVo;
import com.tm.service.SysuserService;
import com.tm.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysuserServceImpl implements SysuserService {
    @Autowired
    private SysuserMapper sysuserMapper;
    @Override
    public SysuserPojo login(String username, String password) {
        SysuserPojo sysuserPojo= sysuserMapper.queryByusername(username);
        if(sysuserPojo!=null){
            String password1 = sysuserPojo.getPassword();
            if(password1.equals(password)){
                return sysuserPojo;
            }else{
                return null;
            }
        }else {
            return null;
        }
        }

    @Override
    public PageUtil querySysuser(SysuserVo sysuserVo) {
        PageUtil pageUtil = new PageUtil();
        Long total= sysuserMapper.queryCount(sysuserVo);
        pageUtil.setTotalCount(total);
        List<SysuserPojo>list= sysuserMapper.querySysuser(sysuserVo);
        pageUtil.setData(list);
        return pageUtil;
    }

    @Override
    public void addSysuser(SysuserPojo sysuserPojo) {
        sysuserMapper.addSysuser(sysuserPojo);
    }

    @Override
    public void updateSysuser(SysuserPojo sysuserPojo) {
        sysuserMapper.updateSysuser(sysuserPojo);
    }

    @Override
    public void deleteSysuser(Integer id) {
        sysuserMapper.deleteSysuser(id);
    }

    @Override
    public void deleteAll(String[] str) {
        sysuserMapper.deleteAll(str);
    }

}
